<template>
  <div class="container">
    <div class="title">
      <img :src="src" alt="" class="headPortrait">
      <h1>{{ list.name }}</h1>
    </div>

    <div
      v-for="item in MySong"
      :key="item.id"
      class="title-button"
      @dblclick="playMusic(item.id)"
    >
      <img :src="item.al.picUrl" alt="">
      <div class="title-and-artist">
        <div class="title">{{ item.name }}</div>
        <div class="artist">{{ item.ar[0].name }}</div>
      </div>
      <div class="album">
        <a>{{ item.al.name }}</a>
      </div>
      <div class="actions">
        <!-- <i v-if="aiXin" class="iconfont icon-aixin" /> -->
        <i class="iconfont icon-shixin" />
      </div>
      <div class="time">{{ item.dt | timeSre }}</div>
    </div>
  </div>
</template>

<script>
import { getSonglistDetails } from '@/api/MS/index.js'

export default {
  filters: {
    timeSre: function(time) {
      var times = new Date(time)
      var m = times.getMinutes() >= 10 ? times.getMinutes() : times.getMinutes()

      var s =
        times.getSeconds() >= 10 ? times.getSeconds() : '0' + times.getSeconds()

      var timestr = m + ':' + s
      return timestr
    }
  },
  data() {
    return {
      name: 'liked',
      cookie: this.$store.state.cookie,
      list: {},
      MySong: {},
      uid: this.$route.params.id,
      aiXin: false,
      src: ''
      // message: 0
    }
  },
  created() {
    this.getSonglistDetails()
  },
  mounted() {},
  methods: {
    async getSonglistDetails() {
      const { data } = await getSonglistDetails({
        id: this.uid,
        cookie: this.$store.state.cookie
      })
      this.list = data.playlist
      this.MySong = data.playlist.tracks
      this.src = data.playlist.creator.avatarUrl
    },
    playMusic(id) {
      console.log(id)
    }
  }
}
</script>

<style scoped lang="less">
.container {
  padding-top: 10px;
  .title {
    display: flex;
    align-items: center;
    .headPortrait {
      height: 44px;
      margin-right: 15px;
      vertical-align: -7px;
      border-radius: 50%;
      border: rgba(0, 0, 0, 0.2);
    }
    h1 {
      font-size: 42px;
    }
  }
  .title-button {
    height: 64px;
    display: flex;
    align-items: center;
    img {
      margin-left: 8px;
      border-radius: 8px;
      height: 46px;
      width: 46px;
      margin-right: 20px;
      border: 1px solid rgba(0, 0, 0, 0.04);
      cursor: pointer;
    }
    .title-and-artist {
      flex: 1;
      display: flex;
      flex-direction: column;
      .title {
        font-size: 18px;
        font-weight: 600;
        color: #000;
        cursor: default;
        padding-right: 16px;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 1;
        overflow: hidden;
        word-break: break-all;
      }
      .artist:hover {
        text-decoration: underline;
        cursor: pointer;
      }
      .artist {
        margin-top: 4px;
        font-size: 13px;
        opacity: 0.68;
      }
    }
    .album {
      flex: 1;
      display: flex;
      font-size: 16px;
      opacity: 0.88;
      color: var(--color-text);
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
      overflow: hidden;
      a {
        color: inherit;
        text-decoration: none;
        cursor: pointer;
      }
    }
    .album:hover {
      text-decoration: underline;
      cursor: pointer;
    }
    .actions {
      padding-right: 25px;
      width: 80px;
      display: flex;
      justify-content: flex-end;
      .icon-shixin {
        color: #335eea;
      }
      i:hover {
        // background-color: #335eea;
        // color: #335eea;
      }
    }
    .time {
      font-size: 16px;
      width: 50px;
      cursor: default;
      display: flex;
      justify-content: flex-end;
      margin-right: 10px;
      font-variant-numeric: tabular-nums;
      opacity: 0.88;
      color: #000;
    }
  }
  .title-button:hover {
    background-color: #f5f5f7;
    border-radius: 15px;
  }
}
</style>
